﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<html>
<body class="no-skin">
    <!-- 以下为内容 -->
    <div class="main-content1">
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try {
                    ace.settings.check('breadcrumbs', 'fixed')
                } catch (e) {
                }
            </script>
            <ul class="breadcrumb" style="margin-top:10px; border:hidden">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="#">个人工作台</a>
                </li>
                <li class="active">个人资料维护</li>
            </ul>
            <!-- 路径结束 -->
        </div>

        <div class="page-content">
            <div class="row">
                <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                    <form id="personalEditForm" class="form-horizontal" role="form">
                        <!-- #section:elements.form -->
                        <div class="form-group">

                            <input type="hidden" id="userId" name="userId" value="${user.userId}"/>

                            <label class="control-label col-xs-12 col-sm-3 control-label no-padding-right"
                                   for="form-field-1">
                                姓名
                            </label>

                            <div class="col-xs-12 col-sm-9">
                                <div class="clearfix">
                                    <input type="text" id="userName" name="userName" maxlength="100"
                                           class="col-xs-10 col-sm-5" value="${user.userName}"/>
                                </div>
                            </div>
                        </div>

                        <!-- /section:elements.form -->
                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right" for="form-field-select-1">
                                所在部门
                            </label>

                            <div class="col-xs-12 col-sm-9">
                                <div class="clearfix">
                                    <input type="text" id="deptName" disabled="disabled" class="col-xs-10 col-sm-5"
                                           value="${user.deptName}"/>
                                </div>
                            </div>
                        </div>

                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right" for="form-field-1">
                                联系电话
                            </label>

                            <div class="col-xs-12 col-sm-9">
                                <div class="clearfix">
                                    <input type="text" id="mobilephone" name="mobilephone" maxlength="20"
                                           class="col-xs-10 col-sm-5" value="${user.mobilephone}"/>
                                </div>
                            </div>
                        </div>

                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class=" col-xs-12 col-sm-3 control-label no-padding-right" for="form-field-1">
                                联系邮箱
                            </label>

                            <div class="col-sm-9">
                                <div class="clearfix">
                                    <input type="text" id="email" name="email" maxlength="50" class="col-xs-10 col-sm-5"
                                           value="${user.email}"/>
                                </div>
                            </div>
                        </div>

                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right" for="form-field-1">
                                岗位
                            </label>

                            <div class="col-xs-12 col-sm-9">
                                <div class="clearfix">
                                    <input type="text" disabled="disabled" class="col-xs-10 col-sm-5" id="positionName"
                                           value="${user.positionName}"/>
                                </div>
                            </div>
                        </div>

                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right" for="form-field-1">
                                微信号
                            </label>

                            <div class="col-xs-12  col-sm-9">
                                <div class="clearfix">
                                    <input type="text" class="col-xs-10 col-sm-5" maxlength="50" id="weixin" name="weixin"
                                           value="${user.weixin}"/>
                                </div>
                            </div>
                        </div>

                        <div class="space-4"></div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="button" onclick="submitEditPersonForm();">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    提 交
                                </button>

                                <button class="btn" type="reset">
                                    <i class="ace-icon fa fa-undo bigger-110"></i>
                                    重 置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <script src="${resRoot}/plugin/ace-v1.3/assets/js/jquery.validate.min.js"></script>
    <script src="${resRoot}/plugin/jquery-validation/localization/messages_zh.js"></script>
    <script type="text/javascript">
        //提交表单函数
        function submitEditPersonForm() {
            //设置状态值
            if (validateForm()) {
                $.ajax({
                    url: contextPath + "/auth/user/editPersonalInfo.json",
                    type: "post",
                    data: $("#personalEditForm").serialize(),
                    async: false,
                    success: function (data) {
                        var msg = eval("(" + data + ")");
                        $.Alert(msg.message);
                    },
                    error: function () {
                        //$.Alert("服务异常，请稍后尝试！");
                    }
                });
            }
        }

        //客户简称验证
        //jQuery.validator.addMethod("dealerShtNameCheck",function(value,element){
        //  var reg = /^[0-9a-zA-Z]+$/;
        // return this.optional(element) || reg.test(value);
        //},"客户简称只能为字母或数字");

        //表单验证函数
        function validateForm() {
            return $("#personalEditForm").validate({
                errorElement: 'span',
                errorClass: 'help-block',
                focusInvalid: false,
                rules: {
                    "userName": {
                        required: true
                    },
                    "weixin": {
                        required: true
                    },
                    "mobilephone": {
                        required: true,
                        digits: true
                    },
                    "email": {
                        required: true,
                        email: true
                    }
                },

                highlight: function (e) {
                    $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
                },

                success: function (e) {
                    $(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
                    $(e).remove();
                },


                errorPlacement: function (error, element) {
                    if (element.is(':checkbox') || element.is(':radio')) {
                        var controls = element.closest('div[class*="col-"]');
                        if (controls.find(':checkbox,:radio').length > 1) controls.append(error);
                        else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
                    }
                    else if (element.is('.select2')) {
                        error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                    }
                    else if (element.is('.chosen-select')) {
                        error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
                    }
                    else if (element.is('textarea')) {
                        error.appendTo(element.parent());
                    }
                    else if (element.is('input[type=text]')) {
                        error.appendTo(element.parent());
                    }
                    else error.insertAfter(element.parent());
                }
            }).form();
        }
    </script>
</body>
</html>
